//
//  UIResponder+YKOCExectionCore.m
//  YKOCExection
//
//  Created by edward on 2020/5/30.
//  Copyright © 2020 edward. All rights reserved.
//

#import "UIResponder+YKOCExectionCore.h"
#import "YKConst.h"

@implementation UIResponder (YKOCExectionCore)


- (void)routerEventWithName:(NSString *)eventName userInfo:(NSDictionary *)userInfo needBuried:(BOOL)needBuried
{
    if (needBuried) {
        [self handleBuriedWithEventName:eventName userInfo:userInfo];
        needBuried = NO;//埋点完后便把标识改为NO
    }
    [[self nextResponder] routerEventWithName:eventName userInfo:userInfo needBuried:needBuried];
}

- (void)handleBuriedWithEventName:(NSString *)eventName userInfo:(NSDictionary *)userInfo
{
    //数据埋点操作 -暂时埋点写入本地数据中
    NSMutableDictionary *dic = [userInfo mutableCopy];
    [dic setValue:[NSDate date] forKey:@"time"];
    NSMutableDictionary *uInfo = [NSMutableDictionary dictionary];
    [uInfo setValue:eventName forKey:@"eventName"];
    [uInfo setValue:dic.copy forKey:@"userInfo"];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"handleBuried" object:nil userInfo:uInfo.copy];
    //[[YKBaseDBManager sharedInstance]addDataWithTableName:@"needBuried" primaryKey:eventName data:data];
    
}

@end
